package algs4.sort;

import java.util.Random;

public class Test
{
    /* Fields */
    private static final int MAX_SIZE = 25;

    /* Static Methods */
    private static void show(Integer[] a) {
        for (int i = 0; i < a.length; i++)
            System.out.printf("%2d ", a[i]);
        System.out.println();
    }

    /* Main Test */
    public static void main(String[] args) {
        if (args.length != 1) {
            System.out.println("Usage: java algs4.sort.Test N");
            System.exit(1);
        }

        Integer[] a = new Integer[MAX_SIZE];
        Random    r = new Random(System.currentTimeMillis());
        int       n = Integer.parseInt(args[0]);

        while (n > 0) {
            // generate test data
            for (int i = 0; i < MAX_SIZE; i++) a[i] = r.nextInt(100);

            // show data before sorting
            System.out.print("BF: "); show(a);

            // sort
            // Insertion.sort(a);
            // Insertion.sort(a, 2, a.length - 2);
            // InsertionX.sort(a);
            // InsertionX.sort(a, 2, a.length - 2);
            // BinaryInsertion.sort(a);
            // BinaryInsertion.sort(a, 2, a.length - 2);
            // Selection.sort(a);
            // Selection.sort(a, 2, a.length - 2);
            // Shell.sort(a);
            // Shell.sort(a, 2, a.length - 2);
            // Merge.sort(a);
            // Merge.sort(a, 2, a.length - 2);
            // MergeX.sort(a);
            // Merge.sort(a, 2, a.length - 2);
            // Quick.sort(a);
            // Quick.sort(a, 2, a.length - 2);
            // Quick3way.sort(a);
            // Quick3way.sort(a, 2, a.length - 2);
            // QuickX.sort(a);
            // QuickX.sort(a, 2, a.length - 2);
            Heap.sort(a);

            // show data after sorting
            System.out.print("AF: "); show(a);

            // blank line
            System.out.println();

            n--;
        }
    }
}
